﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using Maticsoft.DBUtility;//Please add references
namespace ORSIMS.DAL
{
	/// <summary>
	/// 数据访问类:IMAGE_METADATA_TEST
	/// </summary>
	public partial class IMAGE_METADATA_TEST
	{
		public IMAGE_METADATA_TEST()
		{}
		#region  BasicMethod



		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(ORSIMS.Model.IMAGE_METADATA_TEST model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into IMAGE_METADATA_TEST(");
			strSql.Append("ID,TYPEID,TASKID,IMGID,PLATFORMCARRIER,IMGGENTIME,COORDINATESYSTEM,UPPERLEFTLONG,UPPERLEFTLAT,LOWERRIGHTLONG,LOWERRIGHTLAT,CENTERLONG,CENTERLAT,IMGSIZE,PIXLSDEPTH,IMAGEFORMAT,RESOLUTION,DATARESOURCE,PRODUCTLEVEL,DEALDATE,IMGFILENAME,IMGFILEPATH,IMGDISKINDEX,USERID,METADATADATE,PRIVLEVEL,REMARK,STATUS,PROJECTION,PREVIEWIMG)");
			strSql.Append(" values (");
			strSql.Append(":ID,:TYPEID,:TASKID,:IMGID,:PLATFORMCARRIER,:IMGGENTIME,:COORDINATESYSTEM,:UPPERLEFTLONG,:UPPERLEFTLAT,:LOWERRIGHTLONG,:LOWERRIGHTLAT,:CENTERLONG,:CENTERLAT,:IMGSIZE,:PIXLSDEPTH,:IMAGEFORMAT,:RESOLUTION,:DATARESOURCE,:PRODUCTLEVEL,:DEALDATE,:IMGFILENAME,:IMGFILEPATH,:IMGDISKINDEX,:USERID,:METADATADATE,:PRIVLEVEL,:REMARK,:STATUS,:PROJECTION,:PREVIEWIMG)");
			OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,10),
					new OracleParameter(":TYPEID", OracleType.VarChar,3),
					new OracleParameter(":TASKID", OracleType.VarChar,5),
					new OracleParameter(":IMGID", OracleType.VarChar,32),
					new OracleParameter(":PLATFORMCARRIER", OracleType.VarChar,20),
					new OracleParameter(":IMGGENTIME", OracleType.DateTime),
					new OracleParameter(":COORDINATESYSTEM", OracleType.VarChar,20),
					new OracleParameter(":UPPERLEFTLONG", OracleType.Number,10),
					new OracleParameter(":UPPERLEFTLAT", OracleType.Number,10),
					new OracleParameter(":LOWERRIGHTLONG", OracleType.Number,10),
					new OracleParameter(":LOWERRIGHTLAT", OracleType.Number,10),
					new OracleParameter(":CENTERLONG", OracleType.Number,10),
					new OracleParameter(":CENTERLAT", OracleType.Number,10),
					new OracleParameter(":IMGSIZE", OracleType.VarChar,20),
					new OracleParameter(":PIXLSDEPTH", OracleType.Number,2),
					new OracleParameter(":IMAGEFORMAT", OracleType.VarChar,10),
					new OracleParameter(":RESOLUTION", OracleType.Number,3),
					new OracleParameter(":DATARESOURCE", OracleType.VarChar,10),
					new OracleParameter(":PRODUCTLEVEL", OracleType.Number,2),
					new OracleParameter(":DEALDATE", OracleType.DateTime),
					new OracleParameter(":IMGFILENAME", OracleType.VarChar,255),
					new OracleParameter(":IMGFILEPATH", OracleType.VarChar,255),
					new OracleParameter(":IMGDISKINDEX", OracleType.VarChar,200),
					new OracleParameter(":USERID", OracleType.VarChar,20),
					new OracleParameter(":METADATADATE", OracleType.DateTime),
					new OracleParameter(":PRIVLEVEL", OracleType.Number,1),
					new OracleParameter(":REMARK", OracleType.VarChar,200),
					new OracleParameter(":STATUS", OracleType.Number,1),
					new OracleParameter(":PROJECTION", OracleType.VarChar,50),
					new OracleParameter(":PREVIEWIMG", OracleType.Blob)};
			parameters[0].Value = model.ID;
			parameters[1].Value = model.TYPEID;
			parameters[2].Value = model.TASKID;
			parameters[3].Value = model.IMGID;
			parameters[4].Value = model.PLATFORMCARRIER;
			parameters[5].Value = model.IMGGENTIME;
			parameters[6].Value = model.COORDINATESYSTEM;
			parameters[7].Value = model.UPPERLEFTLONG;
			parameters[8].Value = model.UPPERLEFTLAT;
			parameters[9].Value = model.LOWERRIGHTLONG;
			parameters[10].Value = model.LOWERRIGHTLAT;
			parameters[11].Value = model.CENTERLONG;
			parameters[12].Value = model.CENTERLAT;
			parameters[13].Value = model.IMGSIZE;
			parameters[14].Value = model.PIXLSDEPTH;
			parameters[15].Value = model.IMAGEFORMAT;
			parameters[16].Value = model.RESOLUTION;
			parameters[17].Value = model.DATARESOURCE;
			parameters[18].Value = model.PRODUCTLEVEL;
			parameters[19].Value = model.DEALDATE;
			parameters[20].Value = model.IMGFILENAME;
			parameters[21].Value = model.IMGFILEPATH;
			parameters[22].Value = model.IMGDISKINDEX;
			parameters[23].Value = model.USERID;
			parameters[24].Value = model.METADATADATE;
			parameters[25].Value = model.PRIVLEVEL;
			parameters[26].Value = model.REMARK;
			parameters[27].Value = model.STATUS;
			parameters[28].Value = model.PROJECTION;
			parameters[29].Value = model.PREVIEWIMG;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(ORSIMS.Model.IMAGE_METADATA_TEST model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update IMAGE_METADATA_TEST set ");
			strSql.Append("ID=:ID,");
			strSql.Append("TYPEID=:TYPEID,");
			strSql.Append("TASKID=:TASKID,");
			strSql.Append("IMGID=:IMGID,");
			strSql.Append("PLATFORMCARRIER=:PLATFORMCARRIER,");
			strSql.Append("IMGGENTIME=:IMGGENTIME,");
			strSql.Append("COORDINATESYSTEM=:COORDINATESYSTEM,");
			strSql.Append("UPPERLEFTLONG=:UPPERLEFTLONG,");
			strSql.Append("UPPERLEFTLAT=:UPPERLEFTLAT,");
			strSql.Append("LOWERRIGHTLONG=:LOWERRIGHTLONG,");
			strSql.Append("LOWERRIGHTLAT=:LOWERRIGHTLAT,");
			strSql.Append("CENTERLONG=:CENTERLONG,");
			strSql.Append("CENTERLAT=:CENTERLAT,");
			strSql.Append("IMGSIZE=:IMGSIZE,");
			strSql.Append("PIXLSDEPTH=:PIXLSDEPTH,");
			strSql.Append("IMAGEFORMAT=:IMAGEFORMAT,");
			strSql.Append("RESOLUTION=:RESOLUTION,");
			strSql.Append("DATARESOURCE=:DATARESOURCE,");
			strSql.Append("PRODUCTLEVEL=:PRODUCTLEVEL,");
			strSql.Append("DEALDATE=:DEALDATE,");
			strSql.Append("IMGFILENAME=:IMGFILENAME,");
			strSql.Append("IMGFILEPATH=:IMGFILEPATH,");
			strSql.Append("IMGDISKINDEX=:IMGDISKINDEX,");
			strSql.Append("USERID=:USERID,");
			strSql.Append("METADATADATE=:METADATADATE,");
			strSql.Append("PRIVLEVEL=:PRIVLEVEL,");
			strSql.Append("REMARK=:REMARK,");
			strSql.Append("STATUS=:STATUS,");
			strSql.Append("PROJECTION=:PROJECTION,");
			strSql.Append("PREVIEWIMG=:PREVIEWIMG");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,10),
					new OracleParameter(":TYPEID", OracleType.VarChar,3),
					new OracleParameter(":TASKID", OracleType.VarChar,5),
					new OracleParameter(":IMGID", OracleType.VarChar,32),
					new OracleParameter(":PLATFORMCARRIER", OracleType.VarChar,20),
					new OracleParameter(":IMGGENTIME", OracleType.DateTime),
					new OracleParameter(":COORDINATESYSTEM", OracleType.VarChar,20),
					new OracleParameter(":UPPERLEFTLONG", OracleType.Number,10),
					new OracleParameter(":UPPERLEFTLAT", OracleType.Number,10),
					new OracleParameter(":LOWERRIGHTLONG", OracleType.Number,10),
					new OracleParameter(":LOWERRIGHTLAT", OracleType.Number,10),
					new OracleParameter(":CENTERLONG", OracleType.Number,10),
					new OracleParameter(":CENTERLAT", OracleType.Number,10),
					new OracleParameter(":IMGSIZE", OracleType.VarChar,20),
					new OracleParameter(":PIXLSDEPTH", OracleType.Number,2),
					new OracleParameter(":IMAGEFORMAT", OracleType.VarChar,10),
					new OracleParameter(":RESOLUTION", OracleType.Number,3),
					new OracleParameter(":DATARESOURCE", OracleType.VarChar,10),
					new OracleParameter(":PRODUCTLEVEL", OracleType.Number,2),
					new OracleParameter(":DEALDATE", OracleType.DateTime),
					new OracleParameter(":IMGFILENAME", OracleType.VarChar,255),
					new OracleParameter(":IMGFILEPATH", OracleType.VarChar,255),
					new OracleParameter(":IMGDISKINDEX", OracleType.VarChar,200),
					new OracleParameter(":USERID", OracleType.VarChar,20),
					new OracleParameter(":METADATADATE", OracleType.DateTime),
					new OracleParameter(":PRIVLEVEL", OracleType.Number,1),
					new OracleParameter(":REMARK", OracleType.VarChar,200),
					new OracleParameter(":STATUS", OracleType.Number,1),
					new OracleParameter(":PROJECTION", OracleType.VarChar,50),
					new OracleParameter(":PREVIEWIMG", OracleType.Blob)};
			parameters[0].Value = model.ID;
			parameters[1].Value = model.TYPEID;
			parameters[2].Value = model.TASKID;
			parameters[3].Value = model.IMGID;
			parameters[4].Value = model.PLATFORMCARRIER;
			parameters[5].Value = model.IMGGENTIME;
			parameters[6].Value = model.COORDINATESYSTEM;
			parameters[7].Value = model.UPPERLEFTLONG;
			parameters[8].Value = model.UPPERLEFTLAT;
			parameters[9].Value = model.LOWERRIGHTLONG;
			parameters[10].Value = model.LOWERRIGHTLAT;
			parameters[11].Value = model.CENTERLONG;
			parameters[12].Value = model.CENTERLAT;
			parameters[13].Value = model.IMGSIZE;
			parameters[14].Value = model.PIXLSDEPTH;
			parameters[15].Value = model.IMAGEFORMAT;
			parameters[16].Value = model.RESOLUTION;
			parameters[17].Value = model.DATARESOURCE;
			parameters[18].Value = model.PRODUCTLEVEL;
			parameters[19].Value = model.DEALDATE;
			parameters[20].Value = model.IMGFILENAME;
			parameters[21].Value = model.IMGFILEPATH;
			parameters[22].Value = model.IMGDISKINDEX;
			parameters[23].Value = model.USERID;
			parameters[24].Value = model.METADATADATE;
			parameters[25].Value = model.PRIVLEVEL;
			parameters[26].Value = model.REMARK;
			parameters[27].Value = model.STATUS;
			parameters[28].Value = model.PROJECTION;
			parameters[29].Value = model.PREVIEWIMG;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from IMAGE_METADATA_TEST ");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
			};

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ORSIMS.Model.IMAGE_METADATA_TEST GetModel()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ID,TYPEID,TASKID,IMGID,PLATFORMCARRIER,IMGGENTIME,COORDINATESYSTEM,UPPERLEFTLONG,UPPERLEFTLAT,LOWERRIGHTLONG,LOWERRIGHTLAT,CENTERLONG,CENTERLAT,IMGSIZE,PIXLSDEPTH,IMAGEFORMAT,RESOLUTION,DATARESOURCE,PRODUCTLEVEL,DEALDATE,IMGFILENAME,IMGFILEPATH,IMGDISKINDEX,USERID,METADATADATE,PRIVLEVEL,REMARK,STATUS,PROJECTION,PREVIEWIMG from IMAGE_METADATA_TEST ");
			strSql.Append(" where ");
			OracleParameter[] parameters = {
			};

			ORSIMS.Model.IMAGE_METADATA_TEST model=new ORSIMS.Model.IMAGE_METADATA_TEST();
			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ORSIMS.Model.IMAGE_METADATA_TEST DataRowToModel(DataRow row)
		{
			ORSIMS.Model.IMAGE_METADATA_TEST model=new ORSIMS.Model.IMAGE_METADATA_TEST();
			if (row != null)
			{
				if(row["ID"]!=null && row["ID"].ToString()!="")
				{
					model.ID=decimal.Parse(row["ID"].ToString());
				}
				if(row["TYPEID"]!=null)
				{
					model.TYPEID=row["TYPEID"].ToString();
				}
				if(row["TASKID"]!=null)
				{
					model.TASKID=row["TASKID"].ToString();
				}
				if(row["IMGID"]!=null)
				{
					model.IMGID=row["IMGID"].ToString();
				}
				if(row["PLATFORMCARRIER"]!=null)
				{
					model.PLATFORMCARRIER=row["PLATFORMCARRIER"].ToString();
				}
				if(row["IMGGENTIME"]!=null && row["IMGGENTIME"].ToString()!="")
				{
					model.IMGGENTIME=DateTime.Parse(row["IMGGENTIME"].ToString());
				}
				if(row["COORDINATESYSTEM"]!=null)
				{
					model.COORDINATESYSTEM=row["COORDINATESYSTEM"].ToString();
				}
				if(row["UPPERLEFTLONG"]!=null && row["UPPERLEFTLONG"].ToString()!="")
				{
					model.UPPERLEFTLONG=decimal.Parse(row["UPPERLEFTLONG"].ToString());
				}
				if(row["UPPERLEFTLAT"]!=null && row["UPPERLEFTLAT"].ToString()!="")
				{
					model.UPPERLEFTLAT=decimal.Parse(row["UPPERLEFTLAT"].ToString());
				}
				if(row["LOWERRIGHTLONG"]!=null && row["LOWERRIGHTLONG"].ToString()!="")
				{
					model.LOWERRIGHTLONG=decimal.Parse(row["LOWERRIGHTLONG"].ToString());
				}
				if(row["LOWERRIGHTLAT"]!=null && row["LOWERRIGHTLAT"].ToString()!="")
				{
					model.LOWERRIGHTLAT=decimal.Parse(row["LOWERRIGHTLAT"].ToString());
				}
				if(row["CENTERLONG"]!=null && row["CENTERLONG"].ToString()!="")
				{
					model.CENTERLONG=decimal.Parse(row["CENTERLONG"].ToString());
				}
				if(row["CENTERLAT"]!=null && row["CENTERLAT"].ToString()!="")
				{
					model.CENTERLAT=decimal.Parse(row["CENTERLAT"].ToString());
				}
				if(row["IMGSIZE"]!=null)
				{
					model.IMGSIZE=row["IMGSIZE"].ToString();
				}
				if(row["PIXLSDEPTH"]!=null && row["PIXLSDEPTH"].ToString()!="")
				{
					model.PIXLSDEPTH=decimal.Parse(row["PIXLSDEPTH"].ToString());
				}
				if(row["IMAGEFORMAT"]!=null)
				{
					model.IMAGEFORMAT=row["IMAGEFORMAT"].ToString();
				}
				if(row["RESOLUTION"]!=null && row["RESOLUTION"].ToString()!="")
				{
					model.RESOLUTION=decimal.Parse(row["RESOLUTION"].ToString());
				}
				if(row["DATARESOURCE"]!=null)
				{
					model.DATARESOURCE=row["DATARESOURCE"].ToString();
				}
				if(row["PRODUCTLEVEL"]!=null && row["PRODUCTLEVEL"].ToString()!="")
				{
					model.PRODUCTLEVEL=decimal.Parse(row["PRODUCTLEVEL"].ToString());
				}
				if(row["DEALDATE"]!=null && row["DEALDATE"].ToString()!="")
				{
					model.DEALDATE=DateTime.Parse(row["DEALDATE"].ToString());
				}
				if(row["IMGFILENAME"]!=null)
				{
					model.IMGFILENAME=row["IMGFILENAME"].ToString();
				}
				if(row["IMGFILEPATH"]!=null)
				{
					model.IMGFILEPATH=row["IMGFILEPATH"].ToString();
				}
				if(row["IMGDISKINDEX"]!=null)
				{
					model.IMGDISKINDEX=row["IMGDISKINDEX"].ToString();
				}
				if(row["USERID"]!=null)
				{
					model.USERID=row["USERID"].ToString();
				}
				if(row["METADATADATE"]!=null && row["METADATADATE"].ToString()!="")
				{
					model.METADATADATE=DateTime.Parse(row["METADATADATE"].ToString());
				}
				if(row["PRIVLEVEL"]!=null && row["PRIVLEVEL"].ToString()!="")
				{
					model.PRIVLEVEL=decimal.Parse(row["PRIVLEVEL"].ToString());
				}
				if(row["REMARK"]!=null)
				{
					model.REMARK=row["REMARK"].ToString();
				}
				if(row["STATUS"]!=null && row["STATUS"].ToString()!="")
				{
					model.STATUS=decimal.Parse(row["STATUS"].ToString());
				}
				if(row["PROJECTION"]!=null)
				{
					model.PROJECTION=row["PROJECTION"].ToString();
				}
				if(row["PREVIEWIMG"]!=null && row["PREVIEWIMG"].ToString()!="")
				{
					model.PREVIEWIMG=(byte[])row["PREVIEWIMG"];
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ID,TYPEID,TASKID,IMGID,PLATFORMCARRIER,IMGGENTIME,COORDINATESYSTEM,UPPERLEFTLONG,UPPERLEFTLAT,LOWERRIGHTLONG,LOWERRIGHTLAT,CENTERLONG,CENTERLAT,IMGSIZE,PIXLSDEPTH,IMAGEFORMAT,RESOLUTION,DATARESOURCE,PRODUCTLEVEL,DEALDATE,IMGFILENAME,IMGFILEPATH,IMGDISKINDEX,USERID,METADATADATE,PRIVLEVEL,REMARK,STATUS,PROJECTION,PREVIEWIMG ");
			strSql.Append(" FROM IMAGE_METADATA_TEST ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperOra.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM IMAGE_METADATA_TEST ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T. desc");
			}
			strSql.Append(")AS Row, T.*  from IMAGE_METADATA_TEST T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperOra.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			OracleParameter[] parameters = {
					new OracleParameter(":tblName", OracleType.VarChar, 255),
					new OracleParameter(":fldName", OracleType.VarChar, 255),
					new OracleParameter(":PageSize", OracleType.Number),
					new OracleParameter(":PageIndex", OracleType.Number),
					new OracleParameter(":IsReCount", OracleType.Clob),
					new OracleParameter(":OrderType", OracleType.Clob),
					new OracleParameter(":strWhere", OracleType.VarChar,1000),
					};
			parameters[0].Value = "IMAGE_METADATA_TEST";
			parameters[1].Value = "";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperOra.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

